﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using EHTSaleManager.Code.BLL;
using EHTSaleManager.Code.Entity;
using EHTSaleManager.Code.Utility;


namespace EHTSaleManager.UIAdmin
{
    public partial class AdminNewsComfirmDelete : System.Web.UI.Page
    {
        public Int32 NewsID = -1;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["NewsID"] != null)
            {
                try
                {
                    NewsID = Int32.Parse(Request.QueryString["NewsID"].ToString());
                }
                catch (Exception ex)
                {
                    NewsID = -1;
                }
            }

            if (NewsID != -1)
            {
                News theNews = NewsProvider.GetNewsbyID(NewsID);
                this.ltrMessage.Text = "Er du sikker sletter nyheter : " + theNews.NewsID;
                ViewState["ID"] = theNews.NewsID;
            }

        }

        protected void btnDelete_Click(object sender, EventArgs e)
        {
            if (ViewState["ID"] != null)
            {
                NewsID = Int32.Parse(ViewState["ID"].ToString());
                NewsProvider.DeleteNews(NewsID);
            }

            Response.Redirect("AdminNews.aspx");

        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            Response.Redirect("AdminNews.aspx");
        }
    }
}